import Vue from 'vue'
import Vuex from 'vuex'
import { getStorage, setStorage, removeStorage } from '@/utils/storage.js'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: getStorage('user'),
    hotcity: getStorage('city'),
    city: getStorage('hkzf_city')
  },
  mutations: {
    initUser(state, payload) {
      state.user = payload
      setStorage('user', payload)
    },
    removeUser(state) {
      state.user = null
      removeStorage('user')
    },
    initCity(state, payload) {
      state.hotcity = payload
      setStorage('city', payload)
    },
    getcity(state, payload) {
      state.city = payload
      setStorage('hkzf_city', payload)
    },
    newcity(state, payload) {
      state.city = getStorage('city')
    }
  },
  actions: {
  },
  modules: {
  }
})
